package cfca.paperless.client.servlet._3_assist._3_10_GetTemplateInfoList;

import cfca.paperless.client.servlet.PaperlessClient;
import cfca.paperless.client.servlet.PaperlessConfig;
import cfca.paperless.client.util.StringUtil;

public class GetTemplateInfoListTest01 {

    public static void main(String[] args) throws Exception {

        PaperlessClient clientAssistBean = new PaperlessClient(PaperlessConfig.assistUrl, 10000, 60000); 

        String requestXml = "<Request><TemplateFormat>pdf</TemplateFormat><HashAlg>md5</HashAlg></Request>";
        
        String tmpXml = clientAssistBean.getTemplateInfoList(requestXml, PaperlessConfig.operatorCode);
        String code = StringUtil.getNodeText(tmpXml, "Code");
        
        
        if (!"200".equals(code)) {
            System.out.println(tmpXml);
        } else {
            Object[] objArr = StringUtil.getXmlFieldArr(tmpXml, "Template");
            for(Object obj : objArr) {
                String templateCode = StringUtil.getXmlField(obj.toString(), "TemplateCode");
                System.out.println("TemplateCode:"+templateCode);
                String version = StringUtil.getXmlField(obj.toString(), "Version");
                System.out.println("Version:" + version);
                String templateName = StringUtil.getXmlField(obj.toString(), "TemplateName");
                System.out.println("TemplateName:"+ templateName);
                String TemplateFormat = StringUtil.getXmlField(obj.toString(), "TemplateFormat");
                System.out.println("TemplateFormat:"+ TemplateFormat);
                String hashValue = StringUtil.getXmlField(obj.toString(), "HashValue");
                System.out.println("HashValue:" + hashValue);
            }
        }
    }
}
